/*
 * Copyright 2018 the original author or authors.
 * 
 * you can use the file or import project.but Do not take legal responsibility.
 * Only for learning communication.
 *
 * Java compiled version 1.8 or higher
 * 
 * 
 * 
 * 
 */
 
package org.demo.util;

/**
 * 字符串处理工具
 * @author jx-air
 * @date 2018年2月24日 上午10:14:23
 * @version 1.0
 */
public class ExaStringUtil {

	/**
	 * 
	 * 判断字符串是否为空，字符串为null、空格（全角或半角）、Tab、换行(\r或\n)等返回true，包含字符返回false.<br/>
	 * 参考apache commons-lang3的StringUtils
	 * <pre>
     * StringUtil.isBlank(null)      = true
     * StringUtil.isBlank("")        = true
     * StringUtil.isBlank(" ")       = true
     * StringUtil.isBlank("bob")     = false
     * StringUtil.isBlank("  bob  ") = false
     * </pre>
	 * @param cs the CharSequence to check, may be null
	 * @return {@code true} if the CharSequence is null, empty or whitespace only
	 * @see 
	 */
    public static boolean isBlank(final CharSequence cs) {
    	 int strLen;
         if (cs == null || (strLen = cs.length()) == 0) {
             return true;
         }
         for (int i = 0; i < strLen; i++) {
             if (!Character.isWhitespace(cs.charAt(i))) {
                 return false;
             }
         }
         return true;
    }
    /**
     * 判断字符串是否非空，参考 {@link #isBlank} 
     * @param cs
     * @return
     * @see #isBlank
     */
    public static boolean isNotBlank(final CharSequence cs) {
    	return !isBlank(cs);
    }
}
